package com.foxzzz.binary.search;

public class Solution162 {
    public int findPeakElement(int[] nums) {
        for (int i = 0; i < nums.length; i++) {
            if ((i - 1 < 0 || nums[i] > nums[i - 1]) && (i + 1 == nums.length || nums[i] > nums[i + 1]))
                return i;
        }
        return -1;
    }

    public static void main(String[] args) {
        System.out.println(new Solution162().findPeakElement(new int[]{1,2,1,3,5,6,4}));
        System.out.println(new Solution162().findPeakElement(new int[]{2, 1}));
    }
}
